<template>
    <div class="header">
        <span @click="back" v-show="hasBack" class="back">返回</span>
        <h2>{{ title }}</h2>
    </div>
</template>

<script>
    export default {
        data() {
            return {
                show: false
            }
        },
        props: {
            hasBack: {
                type: Boolean,
                default: true
            },
            title: {
                type: String,
                default: '这里是header'
            }
        },
        methods: {
            // 返回
            back () {
                this.$emit('back', 123)
            }
        },
        mounted () {
            console.log('this is header')
        }
    }
</script>

<style scoped>
.header {
    border: 1px solid black;
    position: relative;
}
.back {
    position: absolute;
    left: 0;
    top: 22px;
    left: 10px;
}
</style>